package com.example.baselibrary.Base;

import android.app.Application;
import android.os.Handler;
import android.os.Looper;

import com.example.baselibrary.Utils.DeviceIdHelp;
import com.example.baselibrary.Utils.LogUtil;
import com.wanjian.cockroach.Cockroach;

public class MyApplication extends Application {

    private static MyApplication instance;

    public static MyApplication getAppContext() {
        return instance;
    }


    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;

        // 防止崩溃
//        initCock();

        //获取设备唯一标识
        DeviceIdHelp.getDeviceId(this);
    }


    private void initCock() {
        Cockroach.install(new Cockroach.ExceptionHandler() {
            @Override
            public void handlerException(final Thread thread, final Throwable throwable) {
                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            LogUtil.d("damo - zyf Exception Happend\n" + thread + "\n" + throwable.toString());
                        } catch (Throwable e) {

                        }

                    }
                });
            }
        });
    }

}
